<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<rich:modalPanel id="editPanel" autosized="true">
		<f:facet name="header">
			<h:outputText value="#{messages['button.edit']}" rendered="#{buildingPermitHelper.editMode == '1'}"/>
			<h:outputText value="#{messages['button.add']}" rendered="#{buildingPermitHelper.editMode == '0'}"/>
		</f:facet>

		<h:form>
			<a4j:jsFunction name="refreshInfo" reRender="info">
			</a4j:jsFunction>
			<h:panelGrid id="info" columns="2">
				<h:outputText value="#{messages['intro2.file']}:"/>
				<h:panelGroup>
					<h:outputText rendered="#{buildingPermitHelper.selectedFile != null}" id="nombreArchivo" value="#{buildingPermitHelper.selectedFile.fileName}"/>
					<rich:fileUpload rendered="#{buildingPermitHelper.selectedFile == null}" acceptedTypes="gif,jpg,png,pdf,doc,xls"
							allowFlash="false" autoclear="false" noDuplicate="true"
							maxFilesQuantity="1" immediateUpload="true" clearAllControlLabel="" clearControlLabel=""
							fileUploadListener="#{buildingPermitHelper.attachFileListener}"
							listHeight="80" listWidth="200" addControlLabel="Seleccionar"
							onuploadcomplete="refreshInfo();" ontyperejected="alert('Formato de archivo no soportado. Debe ser jpg, pdf, tiff o png.')">
						<a4j:support event="onuploadcomplete" reRender="info"/>
					</rich:fileUpload>
				</h:panelGroup>
				
				<h:outputText rendered="#{buildingPermitHelper.selectedFile != null}" value="#{messages['intro2.description']}:"/>
				<h:panelGroup id="fileDescr">
					<h:inputTextarea rendered="#{buildingPermitHelper.selectedFile != null}" value="#{buildingPermitHelper.selectedFile.descripcion}"
					cols="30" rows="5"/>
				</h:panelGroup>
			</h:panelGrid>

			<br />
			<br />

			<a4j:commandButton value="#{messages['button.ok']}" action="#{buildingPermitHelper.acceptSelectedFile}"
					oncomplete="#{rich:component('editPanel')}.hide()" reRender="tabla"/>
			<a4j:commandButton value="#{messages['button.close']}" oncomplete="#{rich:component('editPanel')}.hide()" />
		</h:form>
	</rich:modalPanel>

</ui:composition>
